<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #tableAfterButtons>
        <button-group :button-groups="buttonGroups" :crud-ref="crudRef" :selected="selected"
                      />
      </template>
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive,computed } from 'vue'
import wisdomService from '@/api/logistics/wisdomService'
import dictHelp from "@/utils/dicthelp.js";
import ButtonGroup from "@cps/actions/buttonGroup.vue";
const crudRef = ref()
const selected = computed(() => crudRef.value?.selecteds)
const buttonGroups = [
{
    title: '批量修改',
    api: wisdomService.batchUpdate,
    auth: ['logistics:wisdomService:batchUpdate'],
    form: {
      columns: [
        {
          title: '新系统服务', dataIndex: 'service_id', formType: 'select',
          virtualListProps:{},
          dict: {
            url: '/logistics/service/list',
            props: {label: 'name', value: 'id'},
            params: {select: 'id,name'},
            translation: true
          }
        },
        {
          title: '货站', dataIndex: 'depot_id', formType: 'select',
          dict: {
            url: '/warehouse/depot/list',
            props: {label: 'name', value: 'id'},
            params: {select: 'id,name'},
            translation: true
          }
        },
      ]
    },
  },
]


const options = reactive({
  id: 'wisdom_service',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: 600
  },
  api: wisdomService.getList,
  add: {
    show: true,
    api: wisdomService.save,
    auth: ['logistics:wisdomService:save']
  },
  edit: {
    show: true,
    api: wisdomService.update,
    auth: ['logistics:wisdomService:update']
  },
  delete: {
    show: true,
    api: wisdomService.deletes,
    auth: ['logistics:wisdomService:delete']
  },
  export: {show: true, url: 'logistics/wisdomService/export', auth: []},
  import: {
    url: 'logistics/wisdomService/import',text: '导入', show: true
  },
})

const columns = reactive([
  {
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入主键"
    }
  },
  {
    title: "新智慧服务名",
    dataIndex: "name",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入新智慧服务名"
    }
  },
  {
    title: "新智慧服务编码",
    dataIndex: "code",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入新智慧服务编码"
    }
  },
  {
    title: "新系统服务",
    dataIndex: "service_id",
    formType: "select",
    dict:dictHelp.service,
    search: true,
    commonRules: {
      required: true,
      message: "请输入新系统服务"
    }
  },
  {
    title: "货站",
    dataIndex: "depot_id",
    formType: "select",
    dict:dictHelp.depot,
    search: true,
    commonRules: {
      required: true,
      message: "请输入货站"
    }
  }
])
</script>
<script> export default { name: 'logistics:wisdomService' } </script>